home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 4
/
The 640 Meg Shareware Studio CD-ROM Volume IV (Data Express)(1994).ISO
/
clang
/
cenvid.zip
/
DELTREE2.BAT
< prev
next >
Wrap
DOS Batch File
|
1993-06-24
|
2KB
|
61 lines
@echo off
REM DelTree2 - Delete a directory, including all files and subdirectories. This
REM is quicker than DelTree1 because it works one directory at a time.
if "%1"=="" GOTO SHOW_HOW
:This is a dangerious function, so make sure they really want it
ECHO THIS WILL DELETE ALL FILES AND DIRECTORIES UNDER %1
ECHO %1 MUST BE A VALID DIRECTORY AND YOU NEED MSDOS 5
CEnvi GetUKey.cmm ARE YOU SURE YOU WANT TO DO THIS? (Y/N) yn
if N==%UKEY% GOTO FINI
:Check that it is a valid file name
CEnvi ValidDir.bat %1 COMPLAIN
if ERRORLEVEL 1 GOTO FINI
:Unset attributes so that all files can be deleted
attrib -H -S -R %1\*.* /s > NUL
:Delete each directory
dir %1 /Ad /f /s /On | cenvi #include '%0,bat,,GOTO END_SOURCE,:END_SOURCE'
GOTO END_SOURCE
// Create list of all the sub-directories
DirCount = 0
while ( NULL != (DirName = gets()) ) {
if ( DirName[strlen(DirName)-1] != '.' ) // dot and double-dot aren't sub-directories
strcpy(DirList[DirCount++],DirName)
}
// for each directory in that list delete all the files and then the directory.
// Do this in reverse order because it's in reverse order so we won't
// try to delete a directory while it still has subdirectories.
for ( i = DirCount; i != 0; i-- ) {
DirName = DirList[i-1]
sprintf(Command,"echo Y | del %s\\*.* > NUL",DirName)
printf("DEL %s\\*.*\n",DirName)
system(Command)
sprintf(Command,"RMDIR %s",DirName)
printf("%s\n",Command)
system(Command)
}
:END_SOURCE
:Finally, delete the directory itself
ECHO DEL %1\*.*
ECHO Y | DEL %1\*.*
ECHO RMDIR %1
RMDIR %1 > NUL
GOTO FINI
:SHOW_HOW
ECHO
ECHO DelTree2.bat - Delete this directory and all files and subdirectories within it.
ECHO
GOTO FINI
:FINI
set UKEY=